package com.fz.dao;

import com.fz.entity.Book;
import com.fz.mapper.BookMapper;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by webrx on 2017-09-12.
 */
@Data
@Repository("abc")  //或者@Service
public class BookDAO implements BookMapper{    //这里是否实现接口都可以，怕方法漏掉而已

    //采用这种模式是因为灵活度高


    @Autowired   //自动装配，省了实例化这个环节
    private BookMapper dao;

    public Book queryById(int id) {
        //比如说这个方法就可以加一些业务判断


        return dao.queryById(id);
    }

    public List<Book> queryAll() {
        return dao.queryAll();
    }

    public int add(Book book) {
        return dao.add(book);
    }

    public int save(String name, double price, String bdate) {
        return dao.save(name,price,bdate);
    }

    public int delete(int id) {
        return dao.delete(id);
    }
}
